Filter hook 'post_type_labels_{$post_type}'

in WP Core File wp-includes/post.php at line 2133

View Source

post_type_labels_{$post_type}

Filter Hook
Description
Filters the labels of a specific post type. The dynamic portion of the hook name, `$post_type`, refers to the post type slug. Possible hook names include: - `post_type_labels_post` - `post_type_labels_page` - `post_type_labels_attachment`

Hook Information

File Location wp-includes/post.php View on GitHub
Hook Type Filter
Line Number 2133

Hook Parameters

Type Name Description
object $labels Object with labels for the post type as member variables.

Usage Examples

Basic Usage
<?php
// Hook into post_type_labels_{$post_type}
add_filter('post_type_labels_{$post_type}', 'my_custom_filter', 10, 1);

function my_custom_filter($labels) {
    // Your custom filtering logic here
    return $labels;
}

Source Code Context

wp-includes/post.php:2133 - How this hook is used in WordPress core
<?php
2128  	 *
2129  	 * @see get_post_type_labels() for the full list of labels.
2130  	 *
2131  	 * @param object $labels Object with labels for the post type as member variables.
2132  	 */
2133  	$labels = apply_filters( "post_type_labels_{$post_type}", $labels );
2134  
2135  	// Ensure that the filtered labels contain all required default values.
2136  	$labels = (object) array_merge( (array) $default_labels, (array) $labels );
2137  
2138  	return $labels;

PHP Documentation

<?php
/**
	 * Filters the labels of a specific post type.
	 *
	 * The dynamic portion of the hook name, `$post_type`, refers to
	 * the post type slug.
	 *
	 * Possible hook names include:
	 *
	 *  - `post_type_labels_post`
	 *  - `post_type_labels_page`
	 *  - `post_type_labels_attachment`
	 *
	 * @since 3.5.0
	 *
	 * @see get_post_type_labels() for the full list of labels.
	 *
	 * @param object $labels Object with labels for the post type as member variables.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/post.php
Related Hooks

Related hooks will be displayed here in future updates.